<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>倒计时</title>
		<script type="text/javascript">
			window.onload = function() {

				var i = 10;

				var out = document.getElementById('out');
				var timer = setInterval(function() {
					if(i == -1) {
						clearInterval(timer); 
						document.write("时间到");
					} else {
						out.innerHTML = i + "秒";
						--i;
					}
				}, 1000);
			}
		</script>
	</head>
	<body>
		<a id="out"></a>
	</body>

</html>